package com.ideal.handler.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.ui.ModelMap;

import com.ideal.handler.constants.ConstantsMapCode;

/**
* @ClassName: AbstractController
* @Description: TODO
* @author YeQing
* @date 2013年8月20日 下午1:40:53
*/
public abstract class AbstractController {

	/**
	* @Title: returnMap
	* @Description: TODO
	* @param @return
	* @return Map<String,Object>
	* @throws
	 */
	protected Map<String, Object> returnMap() {
		return new HashMap<String, Object>();
	}


	/**
	* @Title: Add failMessage
	* @Description: TODO
	* @param @param modelMap
	* @return void
	* @throws
	 */
	protected <T> void failMessage(ModelMap modelMap) {
		modelMap.put(ConstantsMapCode.SUCCESS, Boolean.FALSE);
	}

	/**
	* @Title: Add failMessage and Message detail.
	* @Description: TODO
	* @param @param modelMap
	* @param @param message
	* @return void
	* @throws
	 */
	protected <T> void failMessage(ModelMap modelMap, T message) {
		modelMap.put(ConstantsMapCode.SUCCESS, Boolean.FALSE);
		modelMap.put(ConstantsMapCode.DETAIL, message);
	}


	/**
	* @Title: Add succMessage
	* @Description: TODO
	* @param @param modelMap
	* @return void
	* @throws
	 */
	protected <T> void succMessage(ModelMap modelMap) {
		modelMap.put(ConstantsMapCode.SUCCESS, Boolean.TRUE);
	}


	/**
	* @Title: Add succMessage and Message detail.
	* @Description: TODO
	* @param @param modelMap
	* @param @param message
	* @return void
	* @throws
	 */
	protected <T> void succMessage(ModelMap modelMap, T message) {
		modelMap.put(ConstantsMapCode.SUCCESS, Boolean.TRUE);
		modelMap.put(ConstantsMapCode.DETAIL, message);
	}

	/**
	* @Title: succMessage
	* @Description: TODO
	* @param @param message
	* @param @return
	* @return Map<String,Object>
	* @throws
	 */
	protected Map<String, Object> succMessage(Object message) {
		Map<String, Object> returnMap = new HashMap<String, Object>();

		returnMap.put(ConstantsMapCode.SUCCESS, Boolean.TRUE);
		returnMap.put(ConstantsMapCode.DETAIL, message);

		return returnMap;
	}

	/**
	* @Title: failMessage
	* @Description: TODO
	* @param @param message
	* @param @return
	* @return Map<String,Object>
	* @throws
	 */
	protected Map<String, Object> failMessage(Object message) {
		Map<String, Object> returnMap = new HashMap<String, Object>();

		returnMap.put(ConstantsMapCode.SUCCESS, Boolean.FALSE);
		returnMap.put(ConstantsMapCode.DETAIL, message);

		return returnMap;
	}

	/**
	* @Title: failMessage
	* @Description: TODO
	* @param @param customCode
	* @param @return
	* @return Map<String,Object>
	* @throws
	 */
	protected Map<String, Object> failMessage(String customCode) {
		Map<String, Object> returnMap = new HashMap<String, Object>();

		returnMap.put(ConstantsMapCode.SUCCESS, Boolean.FALSE);
		returnMap.put(ConstantsMapCode.CODE, customCode);

		return returnMap;
	}




}
